/*
** epur_str.c for  in /home/chreti_m//projet/lemin
** 
** Made by max chretien
** Login   <chreti_m@epitech.net>
** 
** Started on  Sat Apr 21 15:23:30 2012 max chretien
** Last update Mon Apr 30 17:53:06 2012 canh-kiet le
*/

#include	"my.h"

static void	check_for_tab(char *str)
{
  int		i;

  i = 0;
  while (str[i])
    {
      if (str[i] == '\t')
	str[i] = ' ';
      i++;
    }
}

static void	epur_area(char *str, int i)
{
  int		j;

  j = i;
  while (str[j] == ' ')
    j++;
  while (str[j])
    str[i++] = str[j++];
  str[i] = 0;
}

void		epur_str(char *str)
{
  int		i;

  i = 0;
  if (str == NULL || !*str)
    return ;
  check_for_tab(str);
  epur_area(str, i);
  while (str[i])
    {
      if (str[i] == ' ' && str[i + 1] != 0)
	epur_area(str, i + 1);
      i++;
    }
  if (str[i - 1] == ' ')
    i--;
  str[i] = 0;
}
